import BuffUtil from '@/BuffUtil';
import Buff from '@/Buff';
import ItemUtil from '@/ItemUtil';
import RandomUtil from '@/RandomUtil';
import UnitCommon from 'code/Core/Common/UnitCommon';
import MovementCommon from 'code/Core/Common/MovementCommon';
import SummonCommon from 'code/Core/Common/SummonCommon';
export default class Item_母蛛之吻 {
    static id = 'C00N';
    static 名称: string = '母蛛之吻';
    static 描述: string = '你好像中毒了，还好像怀孕了';
    static 图标: string = 'ReplaceableTextures\\CommandButtons\\BTNSpiderSilkBroach.blp';
    static buffId: string = 'buff_item_muzhuzhiwen';
    static buffType: AppBuffType = {
        id: 'buff_item_muzhuzhiwen',
        name: Item_母蛛之吻.名称,
        ubertip: Item_母蛛之吻.描述,
        art: Item_母蛛之吻.图标,
        interval: 1,
        onInterval: Item_母蛛之吻.buffInterval,
        dur: 5,
        targetAttach: 'overhead',
        targetArt: 'Abilities\\Spells\\Other\\AcidBomb\\BottleImpact.mdl',
    };
    static missileReach(p: TargetMissileConfig) {
        BuffUtil.addBuff(p.target, Item_母蛛之吻.buffId, p.caster);
    }
    static buffInterval(buff: Buff) {
        DamageSystemInstance.applyPoisionDamage(buff.getParent(), buff.getCaster(), 600);
    }
    static 添加技能(目标: unit) {
        UnitAddAbility(目标, Item_母蛛之吻.id);
    }
    static 升级(u: unit) {
        IncUnitAbilityLevel(u, Item_母蛛之吻.id);
    }
    static 遗忘(u: unit) {
        UnitRemoveAbility(u, Item_母蛛之吻.id);
    }
    constructor() {
        BuffUtil.registerBuffType(Item_母蛛之吻.buffType);
        EventManager.onTakeAttack(Item_母蛛之吻.spellEffect);
        EventManager.单位死亡(Item_母蛛之吻.deathEffect);
    }
    static deathEffect(d: DamageEventData) {
        if (!BuffUtil.hasUnitBuff(d.target, Item_母蛛之吻.buffId)) return;
        let x = GetUnitX(d.target);
        let y = GetUnitY(d.target);
        let fp = UnitCommon.getFullProperty(d.source);
        DestroyEffect(AddSpecialEffect('Abilities\\Spells\\NightElf\\CorrosiveBreath\\ChimaeraAcidTargetArt.mdl', x, y));
        for (let i = 0; i < 2; i++) {
            // CreateUnit(GetOwningPlayer(d.source), 'nspr', x, y, RandomUtil.randomAngle());
            SummonCommon.summon({
                unitTypeId: 'nspr',
                caster: d.source,
                x,
                y,
                attr: {
                    life: fp * 2.5,
                    attack: fp / 5,
                    附加护甲: fp / 10,
                    附加魔抗: fp / 10,
                },
            });
            DestroyEffect(AddSpecialEffect('Abilities\\Spells\\NightElf\\CorrosiveBreath\\ChimaeraAcidTargetArt.mdl', x, y));
        }
    }
    static spellEffect(d: DamageEventData) {
        if (!ItemUtil.isUnitHasItem(d.source, Item_母蛛之吻.id)) return;
        let r = RandomUtil.randomPercent();
        if (r > 0.1) return;
        MovementCommon.TargetMissile({
            missile: 'Abilities\\Spells\\Other\\Parasite\\ParasiteMissile.mdl',
            target: d.target,
            caster: d.source,
            speed: 600,
            radian: 0.15,
            onReach: Item_母蛛之吻.missileReach,
        });
    }
}
